<template>
	<view class="content">
		<view class="note-top">
			<view class="note-title">{{title}}</view>
			<view class="note-date">{{createtime}}</view>
		</view>
		<view class="note-info">
			<u-parse :content="maincontent"/>
			<!-- <view v-html="maincontent"></view> -->
		</view>
		<view class="bottom-box" @tap="readNote()">
			<view class="read-btn" :class="{isread:reading!=0}">{{reading!=0?'我已确认':"确认"}}</view>
		</view>
	</view>
</template>

<script>
	import uParse from '@/components/gaoyia-parse/parse.vue';
	export default {
		components: {
			uParse
		},
		data() {
			return {
				id:"",
				maincontent:"",
				title:"",
				createtime:"",
				reading:0
			};
		},
		onLoad(ops) {
			this.id=ops.id
			this.getNoticeDetails();
		},
		methods:{
			getNoticeDetails(){
				this.$request.post(this.$api.noticeDetails, {
					store_id:uni.getStorageSync('store_id'),
					id:this.id
				}, {
					token:true
				}).then(res => {
					if (res.code==1) {
						let {
							data = {}
						} = res;
						this.title=data.titile
						this.createtime=this.$tools.formatDate(data.createtime)
						this.maincontent=data.maincontent
						this.reading=data.yd||0
					}
				})
			},
			readNote(){
				if(this.reading==1){
					return;
				}
				this.$request.post(this.$api.readNote, {
					store_id:uni.getStorageSync('store_id'),
					notice_id:this.id
				}, {
					token:true
				}).then(res => {
					if (res.code==1) {
						this.$tools.showToast('操作成功')
						this.reading=1
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 32rpx;
	}
	.note-top{
		border-bottom: 4rpx solid #1D1C5C;
		padding-bottom: 24rpx;
		.note-title{
			font-size: 40rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 36rpx;
		}
		.note-date{
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #686786;
			line-height: 36rpx;
			margin-top: 16rpx;
		}
	}
	.note-info{
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 48rpx;
		margin-top: 32rpx;
	}
	.bottom-box{
		background: #1D1C5C;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		padding: 20rpx 0;
		.read-btn{
			width: 322rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background: #26BCFD;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			margin: auto;
		}
		.isread{
			background: #1D1C5C;
		}
	}
</style>
